<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/common/meta.jsp"%>
<title>首页</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script language="javascript">
var m = "";
setInterval("clock()",1000);
function clock(){
	  document.getElementById("show_time").innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());
}
Ext.onReady(function(){
	Ext.QuickTips.init();
	
	var mainPanel = new Ext.TabPanel({
		id:'tab-area',
		region: 'center',
		margins:'0 5 5 0',
        plugins:new Ext.ux.TabCloseMenu(),
        enableTabScroll:true,
		resizeTabs:true,
		minTabWidth:100,
		tabWidth:130,
		defaults:{autoScroll:true,bodyStyle:'padding:5px'},
		activeTab:0,
        items:{
        	id:'tab-welcome',
        	title:'Welcome',
        	//autoLoad:{url:'http://www.baidu.com'},
        	//iconCls:'icon-tab',
        	bodyStyle:'padding:5px',
        	html:'Welcome!!!!',
        	autoScroll:true,
        	closable:false
        }
	});
	
	//菜单树
	var menuTree = new Ext.tree.TreePanel({
	    useArrows: true,
	    autoScroll: true,
	    animate: true,
	    enableDD: false,
	    containerScroll: true,
	    border: false,
	    dataUrl: '${ctx}/user/loadMenu.html',
		title:'菜单',
		region:'west',
		split:true,
		collapsible:true,
		width:200,
		maxsize:400,
		frame:true,
		root: {
            nodeType: 'async',
            text: '系统菜单',
            draggable: false,
            id: '0'
        }
	});

	menuTree.getRootNode().expand(false);
	menuTree.on('click', function(node, e){
		//e.stopEvent();
		//alert("${ctx}");
	    //mainPanel.setTitle(node.attributes.href_url+"_"+node.id);
	    if(node.attributes.canHref == 'true'){
	    	var p = mainPanel.add({
	    		id:'tab_first_menu',
	    		title:node.attributes.text,
	        	closable:true,
	        	layout:'fit',
	        	autoScroll : true
	    	});
	    	//p.show();
	    	mainPanel.setActiveTab(p);
	    	p.load({
	    		url : '${ctx}/'+node.attributes.href_url, //指向我传过来的页面的位置
	    	    discardUrl : true,
	    	    nocache : true,
	    	    text : "页面加载中,请稍候……",
	    	    timeout : 9000,
	    	    scripts : true
	    	});
	    }
   });
	

	new Ext.Viewport({
	    layout: 'border',
	    items: [{
	        region: 'north',
	        xtype:'box',
            el:'header',
	        //html: '<h1 class="x-panel-header">Page Title</h1>',
	        autoHeight: true,
	        border: false,
	        margins: '0 0 5 0'
	    }, 
	    menuTree
	    , {
	        region: 'south',
	        title: 'Title for Panel',
	        collapsible: true,
	        html: 'Information goes here',
	        split: true,
	        height: 100,
	        minHeight: 100
	    },mainPanel],
	    renderTo: Ext.getBody()
	});
});

function logout(){
	if(confirm("确定退出吗?")){
		location.href = "${ctx}/j_spring_security_logout";
	}
}
</script>
</head>
<body >
<div id="header" class="x-panel-header">
	<div style="float:left;margin-left: 10px;color: #FFF">
       <i>Welcome to</i> &nbsp;<b>CONAN-ZONE<b/>
    </div>
    <div style="float:right;margin-right: 10px;color: #FFF">
    	<font id="show_time" style="padding:6px;color: #FFF"></font>|
        <a href="#" onClick="logout();" style="padding:5px;cursor:pointer;color: #FFF">退出</a>
    </div>
</div>
</body>
</html>

